package com.yoyo.series.app;

import android.content.Intent;
import android.os.Bundle;

import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.yoyo.series.MyApplication;
import com.yoyo.series.SplashActivity;

public abstract class BaseFragmentActivity extends SherlockFragmentActivity {

    public BaseFragmentActivity() {

    }

    protected abstract void initializeData();

    protected abstract void initializeViews();

    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        if (MyApplication.mAppState == -1) {
            restartApplication();
        } else {
            setContentView();
            initializeData();
            initializeViews();
        }
    }

    protected void restartApplication() {
        finish();
        Intent intent = new Intent(getApplicationContext(), SplashActivity.class);
        intent.addFlags(0x4000000);
        intent.putExtra("restart_app", true);
        startActivity(intent);
    }

    protected abstract void setContentView();

    protected void setContentView(int i, boolean flag) {
        setContentView(i);
    }
}
